$("#form-user-add").validate({
	rules:{
		loginName:{
			required:true,
			minlength: 2,
			maxlength: 20,
			remote: {
				url: ctx + "system/user/checkLoginNameUnique",
				type: "post",
				dataType: "json",
				data: {
					name : function() {
						return $.trim($("#loginName").val());
					}
				},
				dataFilter: function(data, type) {
					if (data == "0") return true;
					else return false;
				}
			}
		},
		userName:{
			required:true,
		},
		plUserId:{
			required:true,
		},
		kickback:{
			required:true,
		},
		phonenumber:{
			required:true,
			isPhone:true,
			remote: {
				url: ctx + "system/user/checkPhoneUnique",
				type: "post",
				dataType: "json",
				data: {
					name: function () {
						return $.trim($("#phonenumber").val());
					}
				},
				dataFilter: function (data, type) {
					if (data == "0") return true;
					else return false;
				}
			}
		},
		password:{
			required:true,
			minlength: 5,
			maxlength: 20
		}
	},
	messages: {
		"loginName": {
			remote: "用户已经存在"
		},
		"phonenumber":{
			remote: "手机号码已经存在"
		}
	},
	submitHandler:function(form){
		add();
	}
});
function checkStatus() {
	var input = $("#kickback");
	var val = $("#kickbackSelect option:selected").val();
	input.val(val)
}
function add() {
    _ajax_save(ctx + "manage/userAgent/save", $('#form-user-add').serialize());
}